" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
"
"{{{
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"}}}

"一些特殊配置项(非set)
"{{{

"语法高亮
if has("syntax")
  syntax on
endif
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif


"开启类型插件支持(pyflakes)
filetype on
filetype plugin on

if has("autocmd")
  filetype plugin indent on
endif

"source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim


"配色方案
colorscheme   elflord 

"}}}

"大多数SET
"{{{



" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd		" Show (partial) command in status line.
"set showmatch		" Show matching brackets.
"set ignorecase		" Do case insensitive matching
"set smartcase		" Do smart case matching
"set incsearch		" Incremental search
"set autowrite		" Automatically save before commands like :next and :make
"set hidden             " Hide buffers when they are abandoned


"智能提示自动关闭
set completeopt=longest,menu


set backspace=indent,eol,start "任何时候可以用退格

"禁止生成临时文件
set nobackup
set noswapfile

"搜索时忽悠大小写
set ignorecase


set nocp        "设置为扩展模式
"set mouse=v      " 鼠标任何模式可使用
set laststatus=2 "显示状态栏

"关于折叠
set foldenable
set foldmethod=marker
"set foldmethod=manual


" Tab切换成4个空格
set tabstop=4

"Tab转换为空格
set expandtab

" C语言自动缩进4空格
set shiftwidth=4

" 自动缩进
set autoindent
" 高亮当前行
set cursorline

" encoding
set encoding=utf-8
set termencoding=utf-8
if has('win32')
    set fileencoding=chinese
else
    set fileencoding=utf-8
endif
"set fileencodings=ucs-bom,utf-8,chinese,latin-1
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set langmenu=zh_CN.utf-8
" language messages zh_cn.utf-8

"  默认隐藏菜单栏
set guioptions-=m
" 默认隐藏工具栏
set guioptions-=T

set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R

"显示行号
set number
"黏贴 不缩进
"set paste
"ctags 设置
set tags=./tags,tags

"设置空格核缩进的提示
set list
set listchars=tab:\|-,trail:=,extends:>,precedes:<
"启动时不显示提示
set shortmess=atI

"}}}

"一些MAP 和插件配置
"{{{

"     F12编译python
map <c-r> :!python %<cr>

"配置taglist 默认打开list窗口
"let Tlist_Auto_Open=1
"let Tlist_Ctags_Cmd = '/usr/bin/ctags'
"let Tlist_Show_One_File = 1             "不同时显示多个文件的tag，只显示当前文件的
"let Tlist_Exit_OnlyWindow = 1          "如果taglist窗口是最后一个窗口，则退出vim
"let Tlist_Use_Right_Window = 1         "在右侧窗口中显示taglist窗口
map <c-t> :TagbarToggle<CR>
let g:tagbar_ctags_bin = 'ctags'
let g:tagbar_width = 30
"禁用pyflakes quick fix
"let g:pyflakes_use_quickfix = 0



"pydiction 1.2 python auto complete 智能提示的插件安装
"let g:pydiction_location = '~/.vim/vim72/tools/pydiction/complete-dict'
"defalut g:pydiction_menu_height == 15
"let g:pydiction_menu_height = 20

"配置NERDTREE
let NERDChristmasTree=1 "装饰窗体!
let NERDTreeHighlightCursorline=1 "高亮选中行
"let NERDTreeQuitOnOpen=1 "打开文件后自动关闭树
let NERDTreeWinPos='left'  "显示的窗体位置
nnoremap <c-f> :NERDTreeToggle<cr>  "设置映射键位


"let blogit_username='admin' 
"let blogit_password='?' 
"let blogit_url='https://vps.hcbag.com/xmlrpc.php' 

"let blogit_unformat='pandoc --from=html --to=rst --reference-links'
"let blogit_format='pandoc --from=rst --to=html --no-wrap'

"设置标签功能
nnoremap <F5> :tabnew<cr>  "打开新的标签
nnoremap <F6> :tabprev<cr>"上一个标签
nnoremap <F7> :tabnext<cr> "下一个标签

"nnoremap <F9> :TlistToggle<cr>  "打开关键子列表
"let Tlist_Compact_Format=1 "关闭掉帮助 
"let Tlist_WinWidth=25   "设置窗口宽度
"let Tlist_Auto_Update   "开启自动刷新  

nnoremap to :tabnew<cr>
nnoremap tn :tabnext<CR>
nnoremap tp :tabprev<CR>
nnoremap tc :tabclose<CR>
nnoremap tm :tabmove<CR>
nnoremap tf :tabfirst<CR>
nnoremap tl :tablast<CR>


"操系统剪切板 (需要xsel)
if $DISPLAY != '' && executable('xsel')
    nnoremap <silent> "*y :'[,']w !xsel -i -p -l /dev/null<CR>
    nnoremap <silent> "*p :r!xsel -p<CR>
    nnoremap <silent> "+y :'[,']w !xsel -i -b -l /dev/null<CR>
    nnoremap <silent> "+p :r!xsel -b<CR>
endif

"切换菜单和工具栏的显示隐藏   （工具栏的显示被去掉栏）
"map <F12> :if &guioptions =~# 'm' <Bar>
"       	\set guioptions-=T <Bar>
"        \set guioptions-=m <Bar>
"    \else <Bar>
"        \set guioptions-=T <Bar>
"        \set guioptions+=m <Bar>
"    \endif<CR>

"用空格键 莱开关折叠
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>

"配合alt insert model hjkl
"set timeout
"set timeoutlen=1000
"set ttimeout 
"set ttimeoutlen=50
"if !has("gui_running")
"    set <F14>=<ESC>h
"    set <F13>=<ESC>j
"    set <F15>=<ESC>k
"    set <F16>=<ESC>l
"    inoremap <F14> <left>
"    inoremap <F13> <down>
"    inoremap <F15> <up>
"    inoremap <F16> <right>
"else
"    inoremap <A-h> <left>
"    inoremap <A-j> <down>
"    inoremap <A-k> <up>
"    inoremap <A-l> <right>
"endif 

"}}}

"设置状态栏
"{{{
let g:statusline_max_path = 20 "目录的最大长度
"获取工作目录
function! CurDir()
  let p = expand('%:h:p') "relative to current path, and head path only
  let p = substitute(p,'\','/','g')
 
  let p = substitute(p, '^\V' . $HOME, '~', '')
  if len(p) > g:statusline_max_path 
    let p = simplify(p)
    let p = pathshorten(p)
    let p = ! echo 'ok'
  endif
  return p
endfunction
set statusline=
set statusline+=%f "path to the file in the buffer, relative to current directory
set statusline+=\ %h%1*%m%r%w%0* " flag
set statusline+=\ [%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&encoding}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=\ PWD:%r%{CurDir()}%h
set statusline+=\%=\ [H:0x\%.2B]
set statusline+=\ Char:%-14.(%l,%c%V%)\ %<%P
set statusline+=\ Line:%l/%L\ [%{strftime(\"%y/%m/%d\ %H:%M\")}]\ 
"}}}
 

"                                                       寒晨<chen1324@gmail.com>
